package SSF.OS.NetFlow.Filter;

import SSF.OS.NetFlow.*;

public class IpNetFlowDecoder extends Decoder
{
    public int getFieldIndex(String fieldName, byte fieldType)
    {
	if (fieldName.equals("nhi")) {
	    if (fieldType != STRING_TYPE)
		reportMismatch("nhi", fieldType);
	    return 36;
	}	

	if (fieldName.equals("srcAddr")) {
	    if (fieldType != IP_TYPE)
		reportMismatch("srcAddr", fieldType);
	    return 0;
	}

	if (fieldName.equals("dstAddr")) {
	    if (fieldType != IP_TYPE)
		reportMismatch("dstAddr", fieldType);
	    return 4;
	}

	if (fieldName.equals("input")) {
	    if (fieldType != SHORT_TYPE)
		reportMismatch("input", fieldType);
	    return 8;
	}

	if (fieldName.equals("output")) {
	    if (fieldType != SHORT_TYPE)
		reportMismatch("output", fieldType);
	    return 10;
	}

	if (fieldName.equals("nextHop")) {
	    if (fieldType != IP_TYPE)
		reportMismatch("nextHop",fieldType);
	    return 12;
	}

	if (fieldName.equals("dPkts")) {
	    if (fieldType != INT_TYPE)
		reportMismatch("dPkts", fieldType);
	    return 16;
	}

	if (fieldName.equals("dOctets")) {
	    if (fieldType != INT_TYPE)
		reportMismatch("dOctets", fieldType);
	    return 20;
	}

	if (fieldName.equals("First")) {
	    if (fieldType != FLOAT_TYPE)
		reportMismatch("First", fieldType);
	    return 24;
	}

	if (fieldName.equals("Last")) {
	    if (fieldType != FLOAT_TYPE)
		reportMismatch("Last", fieldType);
	    return 28;
	}

	if (fieldName.equals("tcp_flags")) {
	    if (fieldType != BYTE_TYPE)
		reportMismatch("tcp_flags", fieldType);
	    return 32;
	}

	if (fieldName.equals("protocol")) {
	    if (fieldType != BYTE_TYPE)
		reportMismatch("protocol", fieldType);
	    return 33;
	}

	if (fieldName.equals("src_mask")) {
	    if (fieldType != BYTE_TYPE)
		reportMismatch("src_mask", fieldType);
	    return 34;
	}

	if (fieldName.equals("dst_mask")) {
	    if (fieldType != BYTE_TYPE)
		reportMismatch("dst_mask", fieldType);
	    return 35;
	}

	return FIELD_NOT_FOUND;
    }   
}
